package com.lovo.pis.advice;

import com.lovo.pis.constant.MessageCode;
import com.lovo.pis.utils.JsonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class AllControllerAdvice {

    @ExceptionHandler(Exception.class)
    public JsonResult exceptionHandler(Exception e){
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode(MessageCode.ERROR.getCode());
        jsonResult.setMessage(MessageCode.ERROR.getMessage());
        System.err.println("异常信息=========================="+e.getMessage());
        e.printStackTrace();
        return jsonResult;
    }
}
